<template>
	<view class="customer column">
		<view class="flex-1 hb bgf mt20 scrolly">
			<up-cell-group :border="false">
				<up-cell :title="item.title" v-for="(item,index) in customerList" :key="item.name" @click="onTapItem(item)"
					:border="customerList.length-1>index">
					<template #value>
						<view class="align-center">
							<text class="mr10 fs30 color7" v-if="item.name=='customer_wechat_image'">查看</text>
							<text class="mr10 fs30 color7" v-else>{{item.value}}</text>
							<u-image src="https://monvkeji.oss-cn-chengdu.aliyuncs.com/xunche/user/phone.png" width="46rpx"
								height="46rpx" v-if="item.name=='customer_phone'" />
							<u-image src="https://monvkeji.oss-cn-chengdu.aliyuncs.com/xunche/user/copy.png" width="46rpx"
								height="46rpx" v-if="item.name=='customer_wechat'" />
							<u-icon name="photo-fill" v-if="item.name=='customer_wechat_image'" size="46rpx" color="#2a70c4" />
						</view>
					</template>
				</up-cell>
				<!-- <button open-type="contact"
					style="padding: 0;margin: 0;border-radius:0;text-align: left;border: none;background: #fff;">
					<up-cell title="在线客服" isLink :border="false" />
				</button> -->
			</up-cell-group>
		</view>
		<view class="">
			<uni-popup ref="popupRef">
				<view class="popup_content centerV">
					<view class="w100">
						<u-image :src="popupImg" width="500rpx" height="500rpx" radius="20rpx" @click="previewImage(0,popupImg)" />
					</view>
					<view class="mt50" @click="popupRef.close()">
						<u-icon name="close-circle" color="#fff" size="50rpx" />
					</view>
				</view>
			</uni-popup>
		</view>
	</view>
</template>

<script setup>
	import {
		onLoad
	} from "@dcloudio/uni-app";
	import {
		customerInfo
	} from "@/api/user/index";
	import {
		ref
	} from "vue";
	import {
		cellPhone,
		copyText
	} from "@/core/app";
	const customerList = ref([])
	onLoad(async () => {
		customerInfo().then(res => customerList.value = res.data)
	})
	const popupRef = ref(null)
	const onTapItem = (e) => {
		if (e.name == 'customer_phone') return cellPhone(e.value)
		if (e.name == 'customer_wechat') return copyText(e.value)
		if (e.name == 'customer_wechat_image') return popupRef.value.open()
	}
</script>

<style lang="scss" scoped>
	.customer {
		height: 100%;

		:deep(.u-cell__title-text) {
			color: #000;
			font-size: 30rpx;
			font-weight: bold;
		}
	}
</style>